import pymysql


class Handler:
    def __init__(self):
        self.conn = ...

    def connect(self):
        self.conn = pymysql.connect(host='1.14.76.111', user='root', password='YunZGe502', database='WORD')
        self.cursor = self.conn.cursor()

    def FindAll(self):
        self.cursor.execute("select * from Word")
        val = self.cursor.fetchall()
        return val

    def WriteHistory(self, user, rate, cmt=True):
        self.cursor.execute(f"insert into Commit values('{user}','{rate}')")
        if cmt: self.commit_DML()

    def commit_DML(self):
        self.conn.commit()


if __name__ == '__main__':
    handler = Handler()
    print(handler.FindAll())
    handler.WriteHistory("123", '123')
